package ru.fadeev.crammer.ui;

import java.io.File;

import javax.swing.filechooser.FileFilter;

import ru.fadeev.crammer.Utils;


/**
 * ChooserTextFileFilter represents chooser file filter for .txt files
 * @author Konstantin Fadeyev
 *
 */
public class ChooserTextFileFilter extends FileFilter {

    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String extension = Utils.getExtension(f);

        if (extension != null) {
            if (extension.equals("txt")) {
                    return true;
            } else {
                return false;
            }
        }
        return false;
    }

    
    public String getDescription() {
        return "Text Files (*.txt)";
    }
}
